package com.veltri.JDroid;

import java.util.ArrayList;

import android.app.Application;

//class designed to make variables global to entire application
public class MyApplication extends Application {

	// declare application-global variables
	private String sessionID;
	private int timestamp1, timestamp2, timestamp3;
	private int numNewArticles1 = 0, numNewArticles2 = 0, numNewArticles3 = 0;
	private ArrayList<Integer> categories;
	private ArrayList<String> categoryNames;
	private boolean reloadTab = false;
	
	public void logout() {
		setSessionId("");
		setTimestamp( 0, 0);
		setTimestamp( 1, 0);
		setTimestamp( 2, 0);
	}
	
	public void setCategories() {
		categories = new ArrayList<Integer>();
		categories.add(77);
		categories.add(78);
		categories.add(79);
	}

	public boolean isReloadTab() {
		return reloadTab;
	}

	public void setReloadTab(boolean reloadTab) {
		this.reloadTab = reloadTab;
	}

	public int getCategory(int index) {
		return categories.get(index);
	}
	
	public void setCategoryNames() {
		categoryNames = new ArrayList<String>();
		categoryNames.add("Xbox 360");
		categoryNames.add("PS3");
		categoryNames.add("Wii");
	}

	public String getCategoryName(int index) {
		return categoryNames.get(index);
	}

	// getters and setters for variables
	public String getSessionId() {
		return sessionID;
	}

	public void setSessionId(String someVariable) {
		this.sessionID = someVariable;
	}

	public int getTimestamp( int index) {
		switch( index) {
		case 0:
			return timestamp1;
		case 1:
			return timestamp2;
		case 2:
			return timestamp3;
		}
		return 0;
	}

	public void setTimestamp(int index, int timestamp) {
		switch( index) {
		case 0:
			this.timestamp1 = timestamp;
		case 1:
			this.timestamp2 = timestamp;
		case 2:
			this.timestamp3 = timestamp;
		}
	}
	
	public int getNumNewArticles( int index) {
		switch( index) {
		case 0:
			return numNewArticles1;
		case 1:
			return numNewArticles2;
		case 2:
			return numNewArticles3;
		}
		return 0;
	}

	public void setNumNewArticles(int index, int num) {
		switch( index) {
		case 0:
			this.numNewArticles1 = num;
		case 1:
			this.numNewArticles2 = num;
		case 2:
			this.numNewArticles3 = num;
		}
	}
}